/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package alarmlistener.logger;

import alarmlistener.elements.Input;
import alarmlistener.logger.logevent.InputEvent;
import alarmlistener.logger.logevent.InputEventMulticaster;
import alarmlistener.logger.logevent.InputListener;
import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author rbs
 */
public class InputLogger {

    private static InputLogger loggerInstance = null;
    
    ArrayList<Input> inputs;
  
    InputEventMulticaster multicaster = new InputEventMulticaster();

    Date last_update = new Date();
    
    private InputLogger() {
        inputs = new ArrayList<Input>();
    }
    
    
    public static InputLogger getInstance()
    {
        if (loggerInstance == null)
            loggerInstance = new InputLogger();
        
        return loggerInstance;
    }
    
    public void addInput(Input input)
    {
        last_update = new Date();
        inputs.add(input);
        
        multicaster.onEvent(new InputEvent(this, input));
    }
    
    public void addSpecialInput(String input)
    {
        last_update = new Date();
        Input input1 = new Input("", "", "-->" + input, Boolean.TRUE);
        inputs.add(input1);
        
        multicaster.onEvent(new InputEvent(this, input1));
    }
    
    public ArrayList<Input> getInputs()
    {
        return inputs;
    }
    
    public void addInputListener(InputListener listener)
    {
        multicaster.add(listener);
    }

    public Date getLast_update() {
        return last_update;
    }
    
    
    
}
